<div class="cp-box1">    
    <div style="padding: 5px 0px; text-align: right;">
        <a href="#" id="back2baobiao">返回</a>
    </div>

    <table class="u-table2 play_tab_10" id="preWeekTable">
        <thead>
            <tr>
                <th width="16%">游戏</th>
                <th width="16%">注数</th>
                <th width="16%">下注金额</th>
                <th width="16%">返水</th>
                <th width="16%">盈亏</th>
                <th width="">查看注单</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>北京赛车(PK10)</td><td>91</td><td>91</td><td>0</td><td>-1.75</td>
                <td><a href="#">注单详情</a></td>
            </tr>
        </tbody>
    </table>
    <div style="height: 40px;"></div>
</div>
<style type="text/css">
    #preWeekTable a, #back2baobiao {
        color: blue;
    }
</style>
<script>
$("#back2baobiao").click(function() {
    switch_page("center/baobiao", $(".content-wrap"));
});

(function() {
    var date = context.center.date || new Date().Format("yyyy-MM-dd");
    var games = get_game_list();
    var table = $("#preWeekTable tbody"); table.empty();
    for (var i in games) {
        var g = games[i];
        var tr = $("<tr value='" + g + "'></tr>");
        tr.append("<td>" + get_game_display_name(g) + "</td>");
        tr.append("<td class='betCount'></td>");
        tr.append("<td class='betSum'></td>");
        tr.append("<td class='betBack'></td>");
        tr.append("<td class='betProfit'></td>");
        tr.append('<td><a href="#" value="__v__">注单详情</a></td>'.replace(/__v__/, g));
        table.append(tr);
    }

    $("#preWeekTable a").click(function(e) {
        context.center.game = $(e.currentTarget).attr("value");
        switch_page("center/log2", $(".content-wrap"));
    })

    // 拉取各游戏的统计信息
    for (var i in games) {
        queryStatList(games[i], date);
    }

	function queryStatList(g, date) {
		CMD.stat_user_uquery(g, date, date, 5, 1, function(r) {
			var list = r.list;
            var tr = table.find("tr[value='" + g + "']");
            if (Util.isEmpty(list)) {
                tr.find(".betCount").html(0);
                tr.find(".betSum").html(0);
                tr.find(".betBack").html(0);
                tr.find(".betProfit").html(0);
            }
            else {
                var d = list[0];
                tr.find(".betCount").html(d.betCount);
                tr.find(".betSum").html(d.betSum/100);
                tr.find(".betBack").html(d.betBack/100);
                tr.find(".betProfit").html((d.betProfit + d.betBack)/100);
            }
		});
	}
})();
</script>
